package com.cloudtec.yunzonedep.modules.demo.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cloudtec.yunzonedep.modules.demo.entity.Demo;
import com.cloudtec.yunzonedep.modules.demo.mapper.DemoMapper;
import com.cloudtec.yunzonedep.modules.demo.service.DemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("s1")
@Slf4j
public class DemoServiceImpl extends ServiceImpl<DemoMapper, Demo> implements DemoService {
    @Autowired
    private DemoMapper demoMapper;

    @Override
    @Transactional
    public void transactionTest() {
        demoMapper.insert(new Demo().setName("柚子").setAge(12));
        log.info("我来输出一下日志啦~~~~~~");
        demoMapper.updateById(new Demo(1L,"小明",30));
    }

    @Override
    @Cacheable(value="test1",key="#id")
    public Demo queryById(Long id) {
        return demoMapper.selectById(id);
    }
}
